// src/core/ExpressFactory.ts

import express, { Router } from 'express'
import {Express} from 'express'
import useAppOption from '../AppOption/index'

import { Server } from 'http'
import startConfig from "../startConfig";

const router = Router()

const ExpressFactory = {
  create(): { app:Express; server: Server } {
    const app:Express = express()
    // 创建 HTTP 服务器
    const httpServer = require('http').Server(app)
    // 初始化中间件
    startConfig(app)
    useAppOption(app)
    // 启动服务器逻辑放在外部
    return { app, server: httpServer }
  },
}

export default ExpressFactory
